<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>slice()</title>
	</head>
	<body>
		<script>
			// 此方法返回一个新数组对象
			// 新数组对象是原数组的一个浅拷贝
			// begin（包含） ~ end （不包含）

			const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];

			console.log(animals.slice(2));
			// expected output: Array ["camel", "duck", "elephant"]

			console.log(animals.slice(2, 4));
			// expected output: Array ["camel", "duck"]

			console.log(animals.slice(1, 5));
			// expected output: Array ["bison", "camel", "duck", "elephant"]

			console.log(animals.slice(-2));
			// expected output: Array ["duck", "elephant"]

			console.log(animals.slice(2, -1));
			// expected output: Array ["camel", "duck"]
		</script>
	</body>
</html>
